package com.cms.admin.service.erxinliangbiao.impl;


import com.cms.admin.mapper.PatientListMapper;
import com.cms.admin.mapper.RateScalesPatientMapper;
import com.cms.admin.mapper.UserListMapper;
import com.cms.admin.model.PageBean;
import com.cms.admin.model.*;
import com.cms.admin.service.erxinliangbiao.RateScalesPatientService;
import io.rong.methods.User;

import java.util.Date;
import java.util.List;

/**
 * Created by Faroe on 2017/9/7.
 */
public class RateScalesPatientServiceImpl implements RateScalesPatientService{
    private RateScalesPatientMapper rateScalesPatientMapper;
    private UserListMapper userListMapper;
    private PatientListMapper patientListMapper;


    @Override
    public List<PatientList> getPatientList(String phoneNumber){
        UserList userList = userListMapper.getUserByUserNo(phoneNumber);
        List<PatientList> patientLists = patientListMapper.selectByUserId(userList.getUserid());
        for (int i = 0; i < patientLists.size();i++){
            PatientList patientList = patientLists.get(i);
            Date birthdayDate = patientList.getBirthdayDate();
            String a = String.format("%tF", birthdayDate);
            patientList.setBirthdayDateStr(a);
        }
        return patientLists;
    }

    @Override
    public List<RateScalesPatient> getRateScalesPatient(String phoneNumber){
        UserList userList1 = userListMapper.getUserByUserNo(phoneNumber);
        List<RateScalesPatient> rateScalesPatients = rateScalesPatientMapper.selectByUserId(userList1.getUserid());
        for (int i = 0; i < rateScalesPatients.size();i++){
            RateScalesPatient RateScalesPatient = rateScalesPatients.get(i);
            Date birthdayDate = RateScalesPatient.getBirthdayDate();
            String a = String.format("%tF", birthdayDate);
            RateScalesPatient.setBirthdayDateStr(a);

            Date createDate = RateScalesPatient.getCreateDate();
            String b = String.format("%tF %tR",createDate,createDate);
            RateScalesPatient.setCreateDateStr(b);
        }

        return rateScalesPatients;
    }


    @Override
    public int saveErXinLiangBiaoScore(RateScalesPatientExample rateScalesPatientExample){
        Date creatDate = new Date();
        rateScalesPatientExample.setCreateDate(creatDate);
        return rateScalesPatientMapper.insert(rateScalesPatientExample);
    }

    public RateScalesPatientMapper getRateScalesPatientMapper() {
        return rateScalesPatientMapper;
    }
    public void setRateScalesPatientMapper(RateScalesPatientMapper rateScalesPatientMapper) {
        this.rateScalesPatientMapper = rateScalesPatientMapper;
    }

    public PatientListMapper getPatientListMapper() {
        return patientListMapper;
    }
    public void setPatientListMapper(PatientListMapper patientListMapper) {
        this.patientListMapper = patientListMapper;
    }


    public UserListMapper getUserListMapper() {
        return userListMapper;
    }
    public void setUserListMapper(UserListMapper userListMapper) {
        this.userListMapper = userListMapper;
    }
}
